function [ ] = pdfPlot( HedgeError, steps )
%PROJECT3 Summary of this function goes here
%  This function is used to plot the PDF of the hedging errors
%  Steps: time steps used for generating HedgeError

% Scaling the histogram to get the pdf function
M = length(HedgeError);
errorMax = max(HedgeError)+0.1;
errorMin = min(HedgeError)-0.1;
interval = (errorMax - errorMin)/100;
Bin = errorMin:interval:errorMax;
Pt = histc(HedgeError,Bin)/(interval*M);

bar(Bin,Pt,'histc');
title(['Probability Density Plot for HedgeError with timestep ',num2str(steps)]);
%title(['Probability Density Plot of Discounted Portfolio Value with beta ',num2str(steps)]);

% Calculate Mean, Standard Deviation, VaR, CVaR(95%).
avgError = mean(HedgeError);
stdError = std(HedgeError);
VaR = quantile(HedgeError,0.05);
% CVaR
index = find(HedgeError < VaR);
shortfall = HedgeError(index);
CVaR = mean(shortfall);
fprintf('Mean = %2.8f\n', avgError);
fprintf('Standard Deviation = %2.5f\n', stdError);
fprintf('VAR = %2.5f\n', VaR);
fprintf('CVAR = %2.5f\n', CVaR);

end

